<!--_meta 作为公共模版分离出去-->
<?php $this->_Ameta()?>
<!--/meta 作为公共模版分离出去-->

<title>订单管理</title>
</head>
<body>
<!--_header 作为公共模版分离出去-->
<?php $this->_Aheader()?>
<!--/_header 作为公共模版分离出去-->

<!--_menu 作为公共模版分离出去-->
<?php $this->_Amenu()?>
<!--/_menu 作为公共模版分离出去-->
<section class="Hui-article-box">
    <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span
            class="c-gray en">&gt;</span> 订单管理 <a class="btn btn-success radius r"
                                                  style="line-height:1.6em;margin-top:3px"
                                                  href="javascript:location.replace(location.href);" title="刷新"><i
            class="Hui-iconfont">&#xe68f;</i></a></nav>
    <div class="pd-20 text-c">

        <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l"><a href="javascript:;" onclick="datadel()"
                                                                   class="btn btn-danger radius"><i
                class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>


            <a class="btn btn-primary radius" onclick="system_category_add('添加订单','/admin.php?C=Shop&F=fl_add')"
               href="javascript:;"><i class="Hui-iconfont">&#xe600;</i>
                添加订单</a>


        </span> <span class="r">共有数据：<strong><?php echo count($arr)?></strong> 条</span></div>
        <div class="mt-20">
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                <tr class="text-c">
                    <th width="25"><input type="checkbox" name="" value=""></th>
                    <th width="80">ID</th>
                    <th width="80">订单号</th>
                    <th width="80">账号</th>
                    <th width="80">金额</th>
                    <th width="80">状态</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody>
                <?php foreach($arr as $v){?>
                <tr class="text-c">
                    <td><input type="checkbox" name="id[]" value="<?php echo $v['id']?>"></td>
                    <td><?php echo $v['id']?></td>
                    <td><?php echo $v['ordersn']?></td>
                    <td class="text-l"><?php echo $v['email']?></td>
                    <td><?php echo $v['money']?></td>

                    <td><?php if($v['stat']==1){echo '未付款';}else if($v['stat']=='2'){echo '待发货';}else if($v['stat']==4){echo '待收货';}elseif($v['stat']==5){echo '完成';}elseif($v['stat']==6){echo '退款中';}elseif($v['stat']==7){echo '退款完成';}elseif($v['stat']==3){echo '已取消';}?></td>

                    <td class="f-14" style="text-align:left">
                        <a href="">查看详情</a>
                        &nbsp;&nbsp;
                        <?php if($v['stat']=='2'){?>
                        <a href="" onclick="return fh('<?php echo $v[id]?>')">发货</a>
                        <?php }else if($v['stat']=='4'){?>
                        <a onclick="order_upd('<?php echo $v[id]?>','5')">确认收货</a>
                        <?php }else if($v['stat']=='6'){?>
                        <a onclick="order_upd('<?php echo $v[id]?>','7')">确认退款</a>
                        <?php }else if($v['stat']=='1'){?>
                        <a onclick="order_upd('<?php echo $v[id]?>','2')">付款</a>
                        <?php }?>
                        <a title="删除" href="javascript:;" onclick="system_category_del(this,'<?php echo $v[id]?>')"
                           class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i>
                        </a>
                    </td>
                </tr>
                <?php }?>
                </tbody>
            </table>
        </div>
    </div>

</section>

<!--_footer 作为公共模版分离出去-->
<?php $this->_Afooter()?>
<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/Public/Admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/Public/Admin/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
    /****订单操作*****/
    function fh(id){
        //退出弹框，提供输入 物流号和物流名称
        var wl_h='';
        var wl_n='';
        layer.open({
            type: 1 //Page层类型
            ,btn:["确定","取消"]
            ,title: '填写物流信息'
            ,skin: 'layui-layer-prompt'
            ,content: "<div class=''><input id='wl_h' type='text' class='layui-layer-input' placeholder='物流号'><input type='text' class='layui-layer-input' id='wl_n' placeholder='物流名称'>",yes: function(index, layero){
                 wl_h=$(layero).find('#wl_h').val();
                 wl_n=$(layero).find('#wl_n').val();
                if(wl_h&&wl_h){
                    //ajax请求PHP存储数据
                    $.get('/admin.php?C=Member&F=order_upd',{id:id,type:'fh',wl_h:wl_h,wl_n:wl_n},function(abc){
                        alert(abc.msg);
                        if(abc.type=='2'){
                            window.location.reload();
                        }
                    },'json')
                }
                layer.closeAll();
            }
        });

        return false;
    }

    function order_upd(id,type){
        $.get('/admin.php?C=Member&F=order_upd',{id:id,type:type},function(abc){
            alert(abc.msg);
            if(abc.type=='2'){
                window.location.reload();
            }
        },'json')
    }


    $('.table-sort').dataTable({
        "aaSorting": [[1, "desc"]],//默认第几个排序
        "bStateSave": true,//状态保存
        "aoColumnDefs": [
            //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
            {"orderable": false, "aTargets": [0, 4]}// 制定列不参与排序
        ]
    });

    //    批量删除
    function datadel() {
        //获取所有的多选框
        var chex = $("input:checkbox");
        var id = '';
        chex.each(function (i, itme) {
            if ($(this).is(':checked') == true && $(this).val()) {
                id += $(this).val() + ',';
            }
        });
        var sid = id.substring(0, id.length - 1);
        //发送ajax
        $.get("/admin.php?C=Shop&F=fl_upd", {type: 'del', id: sid}, function (abc) {
            //创建的提示框
            layer.msg(abc.msg, {icon: 1, time: 1000});
            if (abc.type == '1') {
                window.location.reload();
            }

        }, 'JSON');
    }

    /*系统-订单-添加*/
    function system_category_add(title, url, w, h) {
        layer_show(title, url, w, h);
    }
    /*系统-订单-编辑*/
    function system_category_edit(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }


    /*系统-订单-删除*/
    function system_category_del(obj, id) {
        //创建的确认框
        layer.confirm('确认要删除吗？', function (index) {

            $.get("/admin.php?C=Member&F=order_upd", {type: 'del', id: id}, function (abc) {
                if (abc.type == '1') {
                    $(obj).parents("tr").remove();
                }
                //创建的提示框
                layer.msg(abc.msg, {icon: 1, time: 1000});
            }, 'JSON');

        });
    }
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>